import { ApiCall } from "tsrpc";
import { ReqRandom_Job, ResRandom_Job } from "../../../../shared/master/bag/function/PtlRandom_Job";
import app, { xlsxCfgNames } from "../../../../app";
import { player } from "../../../../model/fight/body/player";
import { template } from "../../../../shared/master/MsgAction";
import god from "../../../../god";
import { rank_type } from "../../../../shared/interface";

export default async function (call: ApiCall<ReqRandom_Job, ResRandom_Job>) {
    call.succ({})
    let user = call.req._player as player;
    let res = user.check_wallet(0, 0, [{ id: 'prop-13', v: 1 }], false, '重置血统', true);
    if (!res.state) {
        return;
    }
    let jobTable = app.xlsxCfgMap.get(xlsxCfgNames.血统表) as Map<string,any>;
    let jobArry = [...jobTable.values()];
    let idx = app.random(0,jobArry.length - 1)
    const info = jobArry[idx];
    let add = user.get_DNA_Lv();
    let score = user.reset_job(info.id,add);
    user.rankLog(rank_type.血统资质,score)

    let tpl = user.get_panel_job();

    user.sendMsg(template.panel_job,tpl);
}